What is simple-update-notifier?
The simple-update-notifier package is designed to notify users of your Node.js application when a new version of the application is available. It is particularly useful for CLI tools where maintaining the latest version can be crucial for performance, security, or accessing new features.
What are simple-update-notifier's main functionalities?
Version Check and Notification
This feature automatically checks for updates against the npm registry based on the current package version and notifies the user if a newer version is available. The 'pkg' parameter should be the package.json of the application, which includes the version and name.
const simpleUpdateNotifier = require('simple-update-notifier');
simpleUpdateNotifier({pkg});
Other packages similar to simple-update-notifier
update-notifier
Similar to simple-update-notifier, update-notifier checks for available updates to npm packages and notifies the user. It provides more extensive configuration options, including custom messages, deferment of notification, and frequency of checks.
latest-version
While not providing direct user notifications, latest-version allows you to fetch the latest version of any npm package programmatically. This can be used to inform users of updates in a more customized manner compared to simple-update-notifier.
simple-update-notifier
Simple update notifier to check for npm updates for cli applications.
Checks for updates for an npm module and outputs to the command line if there is one available. The result is cached for the specified time so it doesn't check every time the app runs.
Install
npm install simple-update-notifier
OR
yarn add simple-update-notifier
Usage
import updateNotifier from 'simple-update-notifier';
import packageJson from './package.json' assert { type: 'json' };
updateNotifier({ pkg: packageJson });
Options
pkg
Type: object
name
Required
Type: string
version
Required
Type: string
updateCheckInterval
Type: number
Default: 1000 * 60 * 60 * 24
(1 day)
How often to check for updates.
shouldNotifyInNpmScript
Type: boolean
Default: false
Allows notification to be shown when running as an npm script.
distTag
Type: string
Default: 'latest'
Which dist-tag to use to find the latest version.
alwaysRun
Type: boolean
Default: false
When set, updateCheckInterval
will not be respected and a check for an update will always be performed.
debug
Type: boolean
Default: false
When set, logs explaining the decision will be output to stderr
whenever the module opts to not print an update notification